Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(boxcar): current bucket pre-allocation code is over-allocating #73

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

alexpasmantier
Copy link

@alexpasmantier alexpasmantier commented Feb 3, 2025

From my understanding, this code's intent is to eagerly allocate the next bucket if we're about to write the first entry of the last 1/8th of the current bucket.

                       7/8             1/8  
         <---------------------------><---->
...--]  [========== current bucket =========]  [-------------------------- next bucket...
                                      ↑
                          first entry of the last 1/8th
                          of the current bucket

The code currently checks if:

if index == (location.bucket_len - (location.bucket_len >> 3)) {...}
//                                  -------------------------
//                                 i.e. 1/8 * location.bucket_len

Where index is - if I'm not mistaken a global vector index and should really be location.entry instead which corresponds to the relative location inside the current bucket:

if location.entry == (location.bucket_len - (location.bucket_len >> 3)) {...}

NOTE: in practice, this would mean the current code was over-allocating, by allocating ahead of time for potentially unneeded buckets.

@alexpasmantier alexpasmantier changed the title fix(boxcar): pre-allocation of buckets now checks position inside the current bucket fix(boxcar): current bucket pre-allocation code is over-allocating Feb 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant